﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using ZGLXM.Domain;
using ZGLXM.ErrorCode;
using ZGLXM.Writh.Api.Applicantion.Command.RBAC;

namespace ZGLXM.Writh.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class RoleController : ControllerBase
    {
        private readonly IMediator mediator;
        public RoleController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 添加角色信息
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult> InsertRole(RoleInsertCommand param)
        {
            return await mediator.Send(param);
        }

        /// <summary>
        /// 删除角色信息
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<ApiResult> DeleteRole([FromQuery] RoleDeleteCommand param)
        {
            return await mediator.Send(param);
        }


        /// <summary>
        /// 修改角色信息
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult> UpdateRole(RoleUpdateCommand param)
        {
            return await mediator.Send(param);
        }
    }
}
